import {CustomerPCBAData, CustomerPCBAAdd} from "@/pages/customerConsulting/pcba/type";
import {ReactNode} from "react";
import {UseFetchDataAction} from "@ant-design/pro-table/es/typing";
import {Button, DatePicker, DatePickerProps, Space, Tag} from "antd";
import {ProColumns} from "@ant-design/pro-table";
import {OptionActions} from "@/type/type";
import AddCustomerPCBA from "@/pages/customerConsulting/pcba/list/components/AddCustomerPCBA";
import AuthWrapper from "@/components/AuthWrapper";
import {RangePickerProps} from "antd/es/date-picker/generatePicker";

// @ts-ignore
const columns: ProColumns<CustomerPCBAData> = (optionAction: OptionActions<CustomerPCBAAdd, CustomerPCBAData>,
                                               setCreateTime: any) => {
  return [
    {
      dataIndex: "index",
      valueType: "index",
      hideInSearch: true
    },
    {
      title: " 公司名称",
      dataIndex: "company",
      align: 'center',
      hideInSearch: true

    },
    {
      title: "客户姓名",
      dataIndex: "customerName",
      align: 'center',
    },
    {
      title: " 联系方式",
      dataIndex: "phone",
      align: 'center',
    },
    {
      title: "邮箱",
      dataIndex: "email",
      align: 'center',
      hideInSearch: true
    },
    {
      title: "文件名称",
      dataIndex: "pcbName",
      align: 'center',
      hideInSearch: true
    },
    {
      title: "创建时间",
      dataIndex: "createTime",
      align: 'center',
      renderFormItem: ()=>{
        const { RangePicker } = DatePicker;
        const onOk = (value: DatePickerProps['value'] | RangePickerProps['value']) => {
          console.log('onOk: ', value);
        };
        return (
          <RangePicker
            showTime={{ format: 'HH:mm:ss' }}
            format="YYYY-MM-DD HH:mm:ss"
            onChange={(value, dateString) => {
              console.log('Selected Time: ', value);
              console.log('Formatted Selected Time: ', dateString);
              setCreateTime(dateString);
            }}
            onOk={onOk}
          />
        )
      }
    },
    {
      title: "状态",
      dataIndex: "status",
      align: 'center',
      hideInSearch: true,
      render: (text: ReactNode, record: CustomerPCBAData, index: number, action: UseFetchDataAction<CustomerPCBAData>) =>{
        if (record.status){
          return <Tag color={"success"}>已下载</Tag>
        }else {
          return <Tag >未下载</Tag>

        }
      }
    },
    {
      title: "操作",
      valueType: 'option',
      align: "center",
      key: "option",
      width: "200px",
      render: (text: ReactNode, record: CustomerPCBAData, index: number, action: UseFetchDataAction<CustomerPCBAData>) => {
        return (
          <Space>
            <Button onClick={() => optionAction.download(record.id)}>{record.status?"重新下载":"下载"}</Button>
          </Space>
        )
      }
    }
  ]


}


export default columns;
